﻿
namespace NamedBinaryTag
{
	/// <summary>
	/// Represents a Tag containing a byte.
	/// </summary>
	public sealed class TagByte : NamedTag, IValueTag<byte>
	{
		private byte _value;

		public byte Value
		{
			get { return _value; }
			set { if (_value != value) { _value = value; RaisePropertyChange("Value"); } }
		}

		public override byte TagType
		{
			get { return 1; }
		}

		public override void Read(System.IO.BinaryReader input, bool ignoreName)
		{
			base.Read(input, ignoreName);
			Value = input.ReadByte();
		}

		public override void Write(System.IO.BinaryWriter output, bool ignoreName)
		{
			base.Write(output, ignoreName);
			output.Write(Value);
		}

		public override string ToString()
		{
			return string.Format("TagByte {{ Name = \"{0}\", Value = 0x{1:X2} }}", Name, _value);
		}
	}
}
